package com.icinfo.cloud.provider.punish.common.documentoperate.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.util.ObjectUtils;

/**
 * 描述：文书状态枚举
 *
 * @author xiangyuyu
 * @date 2022/2/24 16:37
 */
@AllArgsConstructor
public enum DocumentStatusEnum {

    /**
     * 文书状态枚举
     */
    WAIT_TO_SUBMIT("APPROVAL_0", "待提交"),
    CHECKING("APPROVAL_1", "审批中"),
    CHECK_END("APPROVAL_2", "已审批"),
    CHECK_BACK("APPROVAL_3", "已退回"),
    WAIT_TO_SEND("SEND_0", "待送达"),
    SENT("SEND_1", "已送达"),
    WAIT_TO_CONFIRM("SIGN_0", "待确认"),
    WAIT_TO_SIGN("SIGN_2", "待填写"),
    WAIT_TO_SIGN_ZLB("SIGN_3", "待签字"),
    CONFIRM_END("SIGN_1", "已确认");

    /**
     * 编码
     */
    @Getter
    private String code;
    /**
     * 描述
     */
    @Getter
    private String des;

    /**
     * 描述：根据code获取value
     *
     * @param code 编码
     * @return 描述内容
     * @author xiangyuyu
     * @date 2022-02-22 10:43
     */
    public static String getValueByCode(String code) {
        if (ObjectUtils.isEmpty(code)) {
            return null;
        }
        for (DocumentStatusEnum e : DocumentStatusEnum.values()) {
            if (code.equals(e.getCode())) {
                return e.getDes();
            }
        }
        return null;
    }

    /**
     * 描述：校验code是否是合法枚举
     *
     * @param code 枚举code
     * @return boolean 是否合法枚举（true-是/false-否）
     * @author xiangyuyu
     * @date 2022-02-22 10:42
     */
    public static boolean isLegalEnumCode(String code) {
        boolean flag = false;
        for (DocumentStatusEnum e : DocumentStatusEnum.values()) {
            if (e.getCode().equalsIgnoreCase(code)) {
                flag = true;
                break;
            }
        }
        return flag;
    }

}
